bpo-29548: Recommend PyObject_Call APIs over PyEval_Call APIs.#75
bpo-29548: Recommend PyObject_Call APIs over PyEval_Call APIs.#75methane merged 1 commit intopython:masterfrom
Conversation
Include/ceval.h
Outdated
There was a problem hiding this comment.
did you ment Use PyObject_Call() it seem like this patch remove PyObject_CallObject ... Autocompleter got a bit overzealous ?
There was a problem hiding this comment.
This patch deprecates PyEval_CallObject, not PyObject_CallObject.
There was a problem hiding this comment.
Oh, sorry, I got confused with the unified diff and above comment, the proximity of PyObject_Call() and PyObject_CallObject() made me think you had an Object too much in the comment.
There was a problem hiding this comment.
There are so many similar call APIs.
That's why I think we should deprecate undocumented and less used APIs.
df67bdc to
89c7440
Compare
89c7440 to
76737a6
Compare
Codecov Report
@@ Coverage Diff @@
## master #75 +/- ##
=========================================
Coverage ? 82.38%
=========================================
Files ? 1428
Lines ? 351138
Branches ? 0
=========================================
Hits ? 289281
Misses ? 61857
Partials ? 0Continue to review full report at Codecov.
|
04111c1 to
7b1dd6e
Compare
|
Sorry but I'm confused by the PR title and the commit messages. They don't describe exactly what I see in the code. Can you please update them? |
|
I updated pull request title and body. |
|
@Haypo Would you review this again? |
Objects/call.c
Outdated
There was a problem hiding this comment.
I don't understand why you change the code in this commit, and 2 commits later reverts this change. You should practice git rebase -i HEAD~4 to merge the two commits maybe?
Objects/call.c
Outdated
There was a problem hiding this comment.
Please update the commit message which doesn't make sense compared to the modified code.
This commit fixes a bug, no? It makes sure that a TypeError is raised if kwargs is not a dictionary, right? Please explain it in the commit message.
There was a problem hiding this comment.
I remove this bugfix for now and update #87 instead.
Objects/call.c
Outdated
Objects/call.c
Outdated
There was a problem hiding this comment.
commit message: this change also optimizes PyEval_CallFunction() and PyEval_CallMethod() to avoid temporary tuple when possible.
There was a problem hiding this comment.
Main purpose is reducing maintenance cost rather than optimization.
There are very few callers in the world.
I hope compiler can remove duplicated code too, but I'm not sure.
Include/ceval.h
Outdated
There was a problem hiding this comment.
I don't understand the "are documented" part, maybe remove it?
I suggest to be more explicit:
" PyEval_CallObjectWithKeywords() is kept for backward compatibility: PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are recommended to call a callable object."
|
I'm not confortable yet with GitHub to review commit messages :-/ It's not easy to comment the commit message: I also suggest to add "bpo-29548" to commit messages (at least to one commit message). |
I agree. I like Gerrit for this.
Final commit message is written when pushing "Squash and merge" button. I hope it works as poor man's Gerrit for a while, until we have new tool to build Misc/NEWS. |
3272dba to
e17b495
Compare
PyEval_Call* APIs are not documented and they doesn't respect PY_SSIZE_T_CLEAN. So add comment block to recommend PyObject_Call* APIs where they are declared. This commit also changes PyEval_CallMethod and PyEval_CallFunction implementation same to PyObject_CallMethod and PyObject_CallFunction to reduce future maintenance cost. Optimization to avoid temporary tuple are copied too. PyEval_CallFunction(callable, "i", (int)i) now calls callable(i) instead of raising TypeError. But accepting this edge case is backward compatible.
e17b495 to
4a3c0d5
Compare
|
I squashed all commit and modified commit message. |
Co-authored-by: Jules <[email protected]>
Stay at eol when moving up/down
PyEval_Call* APIs are not documented and they doesn't respect PY_SSIZE_T_CLEAN.
So add comment block to recommend them where PyEval_Call APIs are declared.
This commit also changes PyEval_CallMethod and PyEval_CallFunction implementation
same to PyObject_CallMethod and PyObject_CallFunction.
PyEval_CallFunction(callable, "i", (int)i)now callscallable(i)instead of raising TypeError.I expect this allows compiler to share some code between PyEval_CallFunction and PyObject_CallFunction. But I'm not sure.
[bpo-29548]